import "phui/style/reset.css";
import "phui/style/vars.css";
import "../less/app.less";
import Input from "phui/lib/Input";
import Button from "phui/lib/Button";
import "../less/login.less";
import { elem, on } from "ph-utils/lib/dom";

const $form = elem("#form")[0] as HTMLFormElement;

const username = new Input("#username", {
  class: "form-input",
  rules: [{ reg: "required", errmsg: "请输入用户名" }],
});

const password = new Input("#password", {
  class: "form-input",
  rules: [{ reg: "required", errmsg: "请输入密码" }],
});

const loginBtn = new Button("#loginBtn", { type: "primary" });

on($form, "submit", (e: Event) => {
  e.preventDefault();
  // 数据验证
  if (username.valid() && password.valid()) {
    const params = {
      username: username.value,
      password: password.value,
    };
    console.log(params);
  }
});
